// array_splice_demo.js

function test1() {
    const months = ['Jan', 'March', 'April', 'June'];
    months.splice(1, 0, 'Feb');
    // inserts at index 1
    console.log(months);
    // expected output: Array ["Jan", "Feb", "March", "April", "June"]

    months.splice(4, 1, 'May');
    // replaces 1 element at index 4
    console.log(months);
    // expected output: Array ["Jan", "Feb", "March", "April", "May"]
}

const arr = [
    { cid: 1001, name: '华为', price: 3200 },
    { cid: 1002, name: '小米', price: 2000 }
];

let index = arr.findIndex(ele => ele.cid == 1002);
console.log(index)

arr.splice(index, 1);

console.log(arr);
